using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace TaskMaster
{
    public partial class TaskSelectionUI : Form
    {
        List<Task> _taskList = new List<Task>();
        Task _selectedTask;

        public TaskSelectionUI(List<Task> taskList)
        {
            InitializeComponent();
            _taskList = taskList;
            comboBox_TaskList.DisplayMember = "TaskName";
            comboBox_TaskList.ValueMember = "TaskId";
            comboBox_TaskList.DataSource = _taskList;       
        }

        private void button_Cancel_Click(object sender, EventArgs e)
        {
            DialogResult = DialogResult.Cancel;
            this.Close();
        }

        private void button_Select_Click(object sender, EventArgs e)
        {
            _selectedTask = (Task)comboBox_TaskList.SelectedItem;
            DialogResult = DialogResult.OK;
        }

        public Task SelectedTask
        {
            get { return _selectedTask; }
        }
    }
}